<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition >
        <p:panel header="Shipping Orders" >
            <p:commandButton ajax="false" action="#{salesOrderEntityController.generateShippingOrders}" 
                             value="Generate Shipping Orders" 
                             disabled="#{!salesOrderEntityController.canRegenerateShippingOrders()}"
                             rendered="#{shippingOrderEntityController.allShippingOrders.size()==0}"/>

            <p:dataTable value="#{shippingOrderEntityController.allShippingOrders}" var="item" >
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListShippingOrderEntityTitle_id}"/>
                    </f:facet>
                    <h:outputText value="#{item.id}"/>
                </p:column>

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListShippingOrderEntityTitle_salesOrder}"/>
                    </f:facet>
                    <h:outputText value="#{item.salesOrder}"/>
                </p:column>

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListShippingOrderEntityTitle_address}"/>
                    </f:facet>
                    <h:outputText value="#{item.address.address}"/>
                </p:column>

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListShippingOrderEntityTitle_dateToShip}"/>
                    </f:facet>
                    <h:outputText value="#{item.dateToShip}">
                        <f:convertDateTime pattern="MM/dd/yyyy" />
                    </h:outputText>
                </p:column>

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListShippingOrderEntityTitle_status}"/>
                    </f:facet>
                    <h:outputText value="#{item.status}"/>
                </p:column>

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListShippingOrderEntityTitle_billingRequest}"/>
                    </f:facet>
                    <h:outputText value="#{item.billingRequest}"/>
                </p:column>

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="Packing Order"/>
                    </f:facet>
                    <h:commandLink value="#{item.packingOrder.id}" action="/entities/packingOrderEntity/View">
                        <f:setPropertyActionListener target="#{packingOrderEntityController.current}" value="#{item.packingOrder}" />
                        <f:setPropertyActionListener target="#{shippingOrderEntityController.current}" value="#{item.packingOrder.shippingOrder}" />
                    </h:commandLink>
                </p:column>

            </p:dataTable>
        </p:panel>
    </ui:composition>

</html>
